package com.hnkywl.sts.service.htgl;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.hnkywl.sts.dao.base.JkpzDao;
import com.hnkywl.sts.dao.cggl.CgdDao;
import com.hnkywl.sts.dao.djgl.JyddDao;
import com.hnkywl.sts.dao.htgl.CghtDao;
import com.hnkywl.sts.dao.htgl.XshtDao;
import com.hnkywl.sts.dao.jhgl.BgjhDao;
import com.hnkywl.sts.dao.jhgl.BgjhhzmxDao;
import com.hnkywl.sts.dao.organ.FkfsDao;
import com.hnkywl.sts.dao.organ.NbgsDao;
import com.hnkywl.sts.dao.sfgl.SkshDao;
import com.hnkywl.sts.dao.tjbb.BzjyjDao;
import com.hnkywl.sts.dao.zjgl.BzjDao;
import com.hnkywl.sts.dao.zjgl.HthkDao;
import com.hnkywl.sts.dao.zjgl.JzjsDao;
import com.hnkywl.sts.entity.base.Jkpz;
import com.hnkywl.sts.entity.djgl.Jydd;
import com.hnkywl.sts.entity.htgl.*;
import com.hnkywl.sts.entity.jhgl.Tpwzjh;
import com.hnkywl.sts.entity.jhgl.Tpwzjhmx;
import com.hnkywl.sts.entity.sfgl.Sfk;
import com.hnkywl.sts.entity.zjgl.Bzj;
import com.hnkywl.sts.entity.zjgl.Bzjyj;
import com.hnkywl.sts.entity.zjgl.Hthk;
import com.hnkywl.sts.entity.zjgl.Jzjs;
import com.hnkywl.sts.service.base.BmService;
import com.hnkywl.sts.service.base.WebserviceTransService;
import com.hnkywl.sts.service.sys.YgService;
import com.hnkywl.sts.service.zjgl.BzjService;
import com.hnkywl.sts.service.zjgl.HthkService;
import com.hnkywl.sts.util.CalcUtils;
import com.hnkywl.sts.util.DateUtil;
import com.hnkywl.sts.util.JsonUtils;
import com.hnkywl.sts.webservice.wly.impl.PutStorageFeedbackService;
import net.ruixin.orm.hibernate.Page;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jettison.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: jerry
 * Date: 13-4-8
 * Time: 下午1:44
 * To change this template use File | Settings | File Templates.
 */
@Service
public class CghtService {
    private CghtDao cghtDao;
    private JzjsDao jzjsDao;
    private NbgsDao nbgsDao;
    private CgdDao cgdDao;

    private BmService bmService;

    private BgjhDao bgjhDao;
    private BgjhhzmxDao bgjhhzmxDao;

    private FkfsDao fkfsDao;

    private WebserviceTransService webserviceTransService;

    private BzjService bzjService;
    private HthkDao hthkDao;
    private XshtDao xshtDao;
    private SkshDao skshDao;
    private BzjDao bzjDao;
    private JkpzDao jkpzDao;
    private BzjyjDao bzjyjDao;
    private HthkService hthkService;
    private JyddDao jyddDao;


    private PutStorageFeedbackService putStorageFeedbackService;

    @Transactional
    public Cght findCghtglDetail(Long id) {
        return this.cghtDao.get(id);
    }


    /**
     * 查询所有采购合同
     *
     * @param pageNo
     * @param pageSize
     * @return
     */
    public String findAllCgHt(String code, String zt, String cglx, String htbh, Long ssgsId, Long ssbmId, Long cgrId, Long hzfId, String qdr, Date startDate, Date endDate, String xhtbm, int pageNo, int pageSize) {
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        Page<Cght> cghtPage = this.cghtDao.findCgHtList(code, zt, cglx, htbh, ssgsId, ssbmId, cgrId, hzfId, qdr, startDate, endDate, xhtbm, pageNo, pageSize);
        String cghtJson = gson.toJson(cghtPage.getResult());
        return "{\"total\":" + cghtPage.getTotalCount() + ",\"rows\":" + cghtJson + "}";
    }

    /**
     * 查询采购合同
     *
     * @return
     */
    public String findAllSimpleCgHt(Long wzjhid, String zt, String htType, String gysmc, int pageNo, int pageSize) {
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        Page cghtPage = this.cghtDao.findCgHtList(wzjhid, zt, null, htType, gysmc, pageNo, pageSize);
        String cghtJson = gson.toJson(cghtPage.getResult());
        return "{\"total\":" + cghtPage.getTotalCount() + ",\"rows\":" + cghtJson + "}";
    }

    /**
     * 查询保证金对映的采购合同
     *
     * @return
     */
    public String findAllBzjCgHt(Long wzjhid, String zt, String htType, String gysmc, int pageNo, int pageSize) {
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        Page cghtPage = this.cghtDao.findCgHtList(null, "ybc", null, gysmc, pageNo, pageSize);
        String cghtJson = gson.toJson(cghtPage.getResult());
        return "{\"total\":" + cghtPage.getTotalCount() + ",\"rows\":" + cghtJson + "}";
    }

    /**
     * 查询采购合同无保证金
     *
     * @return
     */
    public String findAllHthkCgHt(Long wzjhid, String zt, String htType, String gysmc, int pageNo, int pageSize) {
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        Page cghtPage = this.cghtDao.findCgHtList(null, null, null, null, gysmc, pageNo, pageSize);
        String cghtJson = gson.toJson(cghtPage.getResult());
        return "{\"total\":" + cghtPage.getTotalCount() + ",\"rows\":" + cghtJson + "}";
    }


    public String findJzjsCgHt(Integer pageNo, Integer pageSize) {
        Page<Map> page = cghtDao.findjzjsCgHtList(pageNo, pageSize);
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
        String json = gson.toJson(page.getResult());
        return "{\"total\":" + page.getTotalCount() + ",\"rows\":" + json + "}";
        //*Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        // String json = gson.toJson(list);
        // return "{\"rows\":" + json + "}";
    }


    @Transactional
    public String findCghtForZjBzj(Long wzjhid, String zt, String htType, String gysmc, int pageNo, int pageSize) {
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        Page<Bzjyj> page = this.bzjyjDao.findBzjyjList(null, pageNo, pageSize);
        List<Bzjyj> list = page.getResult() == null ? new ArrayList<Bzjyj>() : page.getResult();
        if (list.size() > 0) {
            List<Long> ids = new ArrayList<Long>();
            for (Bzjyj b : list) {
                if ("追加保证金或者提货".equals(b.getZt())) {
                    ids.add(b.getCght().getId());
                }
            }
            if (ids.size() > 0) {
                Page cghtPage = this.cghtDao.findCghtListForZjBzj(ids, null, null, null, null, pageNo, pageSize);
                String cghtJson = gson.toJson(cghtPage.getResult());
                return "{\"total\":" + cghtPage.getTotalCount() + ",\"rows\":" + cghtJson + "}";
            } else {
                return "{\"total\":0,\"rows\":[]}";
            }
        } else {
            return "{\"total\":0,\"rows\":[]}";
        }
    }

    //保供采购单选择保供合同
    public String findAllSimpleBgCgHt(Long htid, String zt, String htType, int pageNo, int pageSize) {
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        Map object = this.cghtDao.findBgCgHtList(htid, zt, htType, pageNo, pageSize);
        String cghtJson = gson.toJson(object);
        return cghtJson;
    }


    /**
     * 查询采购合同
     *
     * @param cghtId 采购合同ID
     * @return
     */
    public Cght findCghtDetail(Long cghtId) {
        return this.cghtDao.get(cghtId);
    }

    /**
     * 采购合同审核
     *
     * @param cghtId
     * @param shzt
     */
    @Transactional
    public synchronized String cghtConfirm(Long cghtId, String shzt) {
        // 采购合同审核将此采购合同的状态变成 “ysp”
        // 将保证金关联的收款变“ytz”
        // 删除对应得保证金记录
        String result = "";
        Cght cght = this.cghtDao.get(cghtId);
        if ("no".equals(shzt)) {
            cght.setZt("ybc");
            List<Bzj> bzjs = bzjDao.findBzjListByCghtId(cghtId);
            if (bzjs != null && bzjs.size() > 0) {
                for (Bzj bzj : bzjs) {
                    Sfk sk = bzj.getSk();
                    sk.setZt("ytz");
                    skshDao.save(sk);
                    bzj.setDeleted(1);
                    bzjDao.save(bzj);
                }
            }
            List<Hthk> hthks = hthkDao.findAllByCght(cght, null);
            if (hthks != null && hthks.size() > 0) {
                for (Hthk hthk : hthks) {
                    Sfk sk2 = hthk.getSk();
                    sk2.setZt("ytz");
                    skshDao.save(sk2);
                    hthk.setDeleted(1);
                    hthkDao.save(hthk);
                }
            }
            cghtDao.save(cght);
            result = "采购合同已驳回!";
        } else if ("yes".equals(shzt)) {
            cght.setZt("ysp");
            cghtDao.save(cght);
            result = "采购合同已通过!";
        }
        return result;
    }

    /**
     * 查询采购合同明细
     *
     * @param cghtId 采购合同ID
     * @return
     */
    public String findCghtmxContent(Long cghtId) {
        Gson gson = new Gson();
        List<Map> cghtmx = this.cghtDao.findCgHtmxContent(cghtId);
        Double sbjs = 0d;
        Double sbsl = 0d;
        Double hsj = 0d;
        Double bhsj = 0d;
        Double hsje = 0d;
        for (Map map : cghtmx) {
            sbjs += map.get("sbjs") == null ? 0d : Double.parseDouble(map.get("sbjs").toString());
            sbsl += map.get("sbsl") == null ? 0d : Double.parseDouble(map.get("sbsl").toString());
            hsj += map.get("hsj") == null ? 0d : Double.parseDouble(map.get("hsj").toString());
            bhsj += map.get("bhsj") == null ? 0d : Double.parseDouble(map.get("bhsj").toString());
            hsje += map.get("hsje") == null ? 0d : Double.parseDouble(map.get("hsje").toString());
        }
        String json = gson.toJson(cghtmx);
        return "{\"rows\":" + json + ",\"footer\":[{\"cd.z\":\"合计:\",\"sbjs\":" + sbjs + ",\"sbsl\":" + sbsl + ",\"hsj\":" + hsj + ",\"bhsj\":" + bhsj + ",\"hsje\":" + hsje + "}]}";
    }

    public String findCghtmxContentForCgd(Long cghtId) {
        Gson gson = new Gson();
        List<Map> cghtmx = this.cghtDao.findCgHtmxContentForCgd(cghtId);
        Double sbjs = 0d;
        Double sbsl = 0d;
        Double hsj = 0d;
        Double bhsj = 0d;
        Double hsje = 0d;
        for (Map map : cghtmx) {
            sbjs += map.get("js") == null ? 0d : Double.parseDouble(map.get("js").toString());
            sbsl += map.get("sbsl") == null ? 0d : Double.parseDouble(map.get("sbsl").toString());
            hsj += map.get("hsj") == null ? 0d : Double.parseDouble(map.get("hsj").toString());
            bhsj += map.get("bhsj") == null ? 0d : Double.parseDouble(map.get("bhsj").toString());
            hsje += map.get("hsje") == null ? 0d : Double.parseDouble(map.get("hsje").toString());
        }
        String json = gson.toJson(cghtmx);
        return "{\"rows\":" + json + ",\"footer\":[{\"cd.z\":\"合计:\",\"js\":" + sbjs + ",\"sbsl\":" + sbsl + ",\"hsj\":" + hsj + ",\"bhsj\":" + bhsj + ",\"hsje\":" + hsje + "}]}";
    }

    /**
     * 保供采购单选择保供合同明细
     *
     * @param cghtId
     * @return
     */
    public String findBgCghtmxContent(Long cghtId, String mxIdsStrig) {
        Gson gson = new Gson();
        String[] mxIdStrig = mxIdsStrig.split(",");
        List<Long> htmxIds = new ArrayList<Long>();
        for (int i = 0; i < mxIdStrig.length; i++) {
            htmxIds.add(Long.parseLong(mxIdStrig[i]));
        }
        List<Map> cghtmx = this.cghtDao.findBgCgHtmxContent(cghtId, htmxIds);
        Double sbsl = 0d;
        Double hsj = 0d;
        Double bhsj = 0d;
        Double hsje = 0d;
        for (Map map : cghtmx) {
            sbsl += map.get("sbsl") == null ? 0d : Double.parseDouble(map.get("sbsl").toString());
            hsj += map.get("hsj") == null ? 0d : Double.parseDouble(map.get("hsj").toString());
            bhsj += map.get("bhsj") == null ? 0d : Double.parseDouble(map.get("bhsj").toString());
            hsje += map.get("hsje") == null ? 0d : Double.parseDouble(map.get("hsje").toString());
        }
        String json = gson.toJson(cghtmx);
        return "{\"rows\":" + json + ",\"footer\":[{\"cd.z\":\"合计:\",\"sbsl\":" + sbsl + ",\"hsj\":" + hsj + ",\"bhsj\":" + bhsj + ",\"hsje\":" + hsje + "}]}";
    }

    /**
     * 查询采购合同明细
     *
     * @param cghtId 采购合同ID
     * @return
     */
    public String findCghtmxDetail(Long cghtId, int pageNo, int pageSize) {
        Gson gson = new Gson();
        Page<Map> cghtmxPage = this.cghtDao.findCgHtmxList(cghtId, pageNo, pageSize);
        Map sum = cghtDao.findXshtHj(cghtId);
        String json = gson.toJson(cghtmxPage.getResult());
        return "{\"total\":" + cghtmxPage.getTotalCount() + ",\"rows\":" + json + ",\"footer\":[{\"cd.z\":\"合计:\",\"js\":" + sum.get("js") + ",\"sbsl\":" + sum.get("sbsl") + ",\"hsje\":" + sum.get("hsje") + "}]}";
    }

    //合同明细导出
    public List<Map> findCghtmx(Long cghtId) {
        Page<Map> cghtmxPage = this.cghtDao.findCgHtmxList(cghtId, 1, -1);
        return cghtmxPage.getResult();
    }

    /**
     * 查询保供合同明细
     *
     * @param bghtId 采购合同ID
     * @return
     */
    public String findBghtmxContent(Long bghtId) {
        Gson gson = new Gson();
        List<Map> cghtmx = this.cghtDao.findCgHtmxContent(bghtId);
        Double sbsl = 0d;
        Double hsj = 0d;
        Double bhsj = 0d;
        Double hsje = 0d;
        Double hszje = 0d;
        for (Map map : cghtmx) {
            sbsl += map.get("sbsl") == null ? 0d : Double.parseDouble(map.get("sbsl").toString());
            hsj += map.get("hsj") == null ? 0d : Double.parseDouble(map.get("hsj").toString());
            bhsj += map.get("bhsj") == null ? 0d : Double.parseDouble(map.get("bhsj").toString());
            hsje = Double.valueOf(map.get("sbsl") == null ? 0d : Double.parseDouble(map.get("sbsl").toString())) * Double.valueOf(map.get("sbsl") == null ? 0d : Double.parseDouble(map.get("hsj").toString()));
            if (map.get("hsje") == null) {
                map.put("hsje", hsje);
            }
            hszje += hsje;
        }

        String json = gson.toJson(cghtmx);
        return "{\"rows\":" + json + ",\"footer\":[{\"cd.z\":\"合计:\",\"sbsl\":" + sbsl + ",\"hsj\":" + hsj + ",\"bhsj\":" + bhsj + ",\"hsje\":" + hszje + "}]}";
    }

    /**
     * 查询保供合同明细
     *
     * @param bghtId 采购合同ID
     * @return
     */
    public String findBghtmxDetail(Long bghtId, int pageNo, int pageSize) {
        Gson gson = new Gson();
        Page<Map> cghtmxPage = this.cghtDao.findCgHtmxList(bghtId, pageNo, pageSize);
        Map sum = cghtDao.findXshtHj(bghtId);
        String json = gson.toJson(cghtmxPage.getResult());
        return "{\"total\":" + cghtmxPage.getTotalCount() + ",\"rows\":" + json + ",\"footer\":[{\"wzgg.dw\":\"合计:\",\"sbsl\":" + sum.get("sbsl") + ",\"hsje\":" + (sum.get("hsje") == null ? "0" : sum.get("hsje")) + "}]}";
//        Gson gson = new Gson();
//        Page<Map> cghtmxMap = this.cghtDao.findCgHtmxList(bghtId, pageNo, pageSize);
//        Double sbsl = 0d;
//        Double hsj = 0d;
//        Double bhsj = 0d;
//        Double hsje = 0d;
//        Double hszje = 0d;
//        for (Map map : cghtmxMap.getResult()) {
//            sbsl += map.get("sbsl") == null ? 0d : Double.parseDouble(map.get("sbsl").toString());
//            hsj += map.get("hsj") == null ? 0d : Double.parseDouble(map.get("hsj").toString());
//            bhsj += map.get("bhsj") == null ? 0d : Double.parseDouble(map.get("bhsj").toString());
//            hsje = Double.valueOf(map.get("sbsl") == null ? 0d : Double.parseDouble(map.get("sbsl").toString())) * Double.valueOf(map.get("sbsl") == null ? 0d : Double.parseDouble(map.get("hsj").toString()));
//            if (map.get("hsje") == null) {
//                map.put("hsje", hsje);
//            }
//            hszje += hsje;
//        }
//
//        String json = gson.toJson(cghtmxMap.getResult());
//        return "{\"total\":" + cghtmxMap.getTotalCount() + ",\"rows\":" + json + ",\"footer\":[{\"cd.z\":\"合计:\",\"sbsl\":" + sbsl + ",\"hsj\":" + hsj + ",\"bhsj\":" + bhsj + ",\"hsje\":" + hszje + "}]}";
    }


    /**
     * 查询采购合同明细
     *
     * @param processInstanceId 协议ID
     * @return
     */
    @Transactional
    public Cght findCghtDetailByProcessInstance(String processInstanceId) {
        return this.cghtDao.findUniqueByProperty("processInstanceId", processInstanceId);
    }

//    /**
//     * 查询采购合同明细
//     *
//     * @param xshtId 售合合同ID
//     * @return
//     */
//    public List<Map> findCghtmxDetailList(Long xshtId) {
//        return this.cghtDao.findCgHtmxList(xshtId);
//    }

    public Cght createCghtByWzjh(Tpwzjh tpwzjh) throws SQLException {
        //生成采购合同
        Cght cght = new Cght();
        cght.setCglx("tpcght");
        cght.setHtbm(this.bmService.getHtbm("CGHT"));
        //cght.setSl(17.00);
        cght.setLj(tpwzjh.getLj());
        cght.setTcgs(tpwzjh.getTcgs()); //统筹公司
        cght.setTcbm(tpwzjh.getTcbm());//统筹部门
        cght.setQdrq(new Date());  //签订日期
        cght.setWzjh(tpwzjh); //绑定采购物资计划
        cght.setHzf(tpwzjh.getGys());
        if (tpwzjh.getTcfs().getZ().equals("统付统购")) {
            cght.setZbcg(true);
            cght.setWlfgs(this.nbgsDao.findAllRootNbgs().get(0));
        } else {
            cght.setZbcg(false);
            cght.setWlfgs(tpwzjh.getSbgs());
        }
        cght.setWlfbm(tpwzjh.getSbbm());
        cght.setSbgs(tpwzjh.getSbgs());
        cght.setSbbm(tpwzjh.getSbbm());
        cght.setSbr(tpwzjh.getCreateUser());
        cght.setWlfry(tpwzjh.getCreateUser());
        cght.setZt("ysp");
        cght.setDateCreated(new Date());
        cght.setCreateUser(tpwzjh.getCreateUser());
        cght.setCreateOrgan(tpwzjh.getCreateOrgan());
        cght.setCreateDepartment(tpwzjh.getCreateDepartment());
        cght.setLastUpdated(cght.getDateCreated());

        //生成采购合同明细
        List<Htmx> htmxList = new ArrayList<Htmx>();
        if (tpwzjh.getTpwzjhmxList() != null) {
            for (Tpwzjhmx temp : tpwzjh.getTpwzjhmxList()) {
                Htmx htmx = new Htmx();
                htmx.setWzgg(temp.getWzgg());
                htmx.setCd(temp.getCd());
                htmx.setCk(temp.getCk());
                htmx.setJzfs(temp.getJzfs());
                htmx.setBz(temp.getBz());
                htmx.setSbsl(Double.parseDouble(temp.getHdsl().toString()));
                htmx.setHt(cght);
                htmx.setZt("ybc");
                htmx.setDateCreated(new Date());
                htmx.setLastUpdated(htmx.getDateCreated());
                htmx.setCreateUser(YgService.getCurrentYg());
                htmx.setCreateOrgan(YgService.getCurrentYg().getZggs());
                htmx.setCreateDepartment(YgService.getCurrentYg().getZgjg());
                htmxList.add(htmx);
            }
        }
        cght.setHtmxList(htmxList);
        this.cghtDao.save(cght);
        return cght;
    }

    /**
     * 保存采购合同信息
     *
     * @param cght 采购合同
     * @return
     */
    @Transactional
    public Cght saveCght(Cght cght) throws SQLException {
        cght.setHtbm(this.bmService.getHtbm("CGHT"));
        if (cght.getSl() != null) {
            java.text.DecimalFormat df = new java.text.DecimalFormat("#0.0000");
            String sl = df.format(cght.getSl());
            cght.setSl(Double.parseDouble(sl));
        }
        if (cght.getLl() != null) {
            java.text.DecimalFormat df = new java.text.DecimalFormat("#0.0000");
            String ll = df.format(cght.getLl());
            cght.setLl(Double.parseDouble(ll));
        }
        cght.setZt("ybc");
        cght.setHtms("xxms");
        cght.setCreateUser(YgService.getCurrentYg());
        cght.setCreateOrgan(YgService.getCurrentYg().getZggs());
        cght.setCreateDepartment(YgService.getCurrentYg().getZgjg());
        cght.setDateCreated(new Date());
        cght.setLastUpdated(cght.getDateCreated());
        int i = 0;
        if (cght.getHtmxList() != null) {
            for (Htmx htmx : cght.getHtmxList()) {
                i++;
                htmx.setHsj(CalcUtils.round(htmx.getHsj(), 4));
                htmx.setBhsj(CalcUtils.round(htmx.getBhsj(), 4));
                htmx.setHsje(CalcUtils.round(htmx.getHsje(), 2));
                htmx.setMxh(Long.valueOf(i));
                htmx.setXsxt_xsdh(htmx.getXsxt_xsdh().trim());
                htmx.setCreateUser(YgService.getCurrentYg());
                htmx.setCreateOrgan(YgService.getCurrentYg().getZggs());
                htmx.setCreateDepartment(YgService.getCurrentYg().getZgjg());
                htmx.setLastUpdated(new Date());
            }
        }

        this.cghtDao.save(cght);
        return cght;
    }

    //保存保供合同
    @Transactional
    public Cght saveBght(Cght bght) throws SQLException {
        bght.setHtbm(this.bmService.getHtbm("CGHT"));
        if (bght.getSl() != null) {
            java.text.DecimalFormat df = new java.text.DecimalFormat("#0.0000");
            String sl = df.format(bght.getSl());
            bght.setSl(Double.parseDouble(sl));
        }
        if (bght.getLl() != null) {
            java.text.DecimalFormat df = new java.text.DecimalFormat("#0.0000");
            String ll = df.format(bght.getLl());
            bght.setLl(Double.parseDouble(ll));
        }
        bght.setZt("ybc");
        bght.setCreateUser(YgService.getCurrentYg());
        bght.setCreateOrgan(YgService.getCurrentYg().getZggs());
        bght.setCreateDepartment(YgService.getCurrentYg().getZgjg());
        bght.setDateCreated(new Date());
        bght.setLastUpdated(bght.getDateCreated());
        this.cghtDao.save(bght);
        return bght;
    }

    //保存结束日期
    @Transactional
    public void saveHtyq(Cght bght) {
        Cght clone = this.findCghtDetail(bght.getId());
        clone.setJsrq(bght.getJsrq());
        clone.setLastUpdated(new Date());
        this.cghtDao.save(clone);
    }

    /**
     * 修改采购合同信息
     *
     * @param cght 采购合同
     * @return
     */
    @Transactional
    public void editCght(Cght cght, String htbm) {
        cght.setHtbm(htbm);
        if (cght.getSl() != null) {
            java.text.DecimalFormat df = new java.text.DecimalFormat("#0.0000");
            String sl = df.format(cght.getSl());
            cght.setSl(Double.parseDouble(sl));
        }
        if (cght.getLl() != null) {
            java.text.DecimalFormat df = new java.text.DecimalFormat("#0.0000");
            String ll = df.format(cght.getLl());
            cght.setLl(Double.parseDouble(ll));
        }
        if (cght.getHtmxList() != null) {
            int i = 0;
            for (Htmx htmx : cght.getHtmxList()) {
                i++;
                if (htmx.getMxh() == null) {
                    htmx.setMxh(Long.valueOf(i));
                }
                htmx.setHsj(CalcUtils.round(htmx.getHsj(), 4));
                htmx.setBhsj(CalcUtils.round(htmx.getBhsj(), 4));
                htmx.setHsje(CalcUtils.round(htmx.getHsje(), 2));
                if (StringUtils.isNotBlank(htmx.getXsxt_xsdh())) {
                    htmx.setXsxt_xsdh(htmx.getXsxt_xsdh().trim());
                }
            }
        }
        cght.setLastUpdated(new Date());
        this.cghtDao.save(cght);
    }


    @Transactional
    public void editCghtForXs(Cght cght) {
        cghtDao.updateCghtFromXs(cght.getMxts(), cght.getTxl(), cght.getYhbl(),cght.getQdrq(),cght.getFksj(),cght.getJhsj(),cght.getId());
    }

    /**
     * 采购合同提交前的保证金的校验
     * 1、此采购合同是否开具保证金
     * 2、根据保证金比例查看他所有缴纳的保证金是否足够
     *
     * @param cght
     * @return
     */
    public String checkBzjFromCght(Cght cght) {
        DecimalFormat df = new DecimalFormat("0.00");
        String result = "";
        List<Bzj> list = this.bzjService.findBzjByCght(cght);
        if (null != list && list.size() > 0) {
            //1、这个采购合同额含税金额
            Double hthsje = cght.getHsze();
            Double bzjlx = list.get(0).getBzjbl();
            Double htbzjje = CalcUtils.mulDouble(hthsje, (bzjlx / 100));
            Double sumSkje = 0.0;
            for (Bzj bzj : list) {
                Double tx = 0.0;
                // 后定价情况,贴息在保证提交时，不扣除
//                if (null != bzj.getSk().getTx()) {
//                    tx = bzj.getSk().getTx();
//                }
                // 状态锁定的
//                if (bzj.getStatus() == 1) {
//                    sumSkje += bzj.getSk().getYe() + tx;
//                }

                //状态锁定的保证金
                if (bzj.getStatus() == 1) {
                    sumSkje += bzj.getYe();
                }
            }
            Double d1 = CalcUtils.round(Double.valueOf(df.format(sumSkje)), 2);
            Double d2 = CalcUtils.round(Double.valueOf(df.format(htbzjje)), 2);
            if (d1 < d2) {
                result = "此合同所需保证金缴纳不足还差" + df.format(d2 - d1) + "元,请确认保证金是已锁定?";
            }
        } else {
            result = "此合同未开具任何保证金!请开具保证金后再提交!";
        }
        return result;
    }


    /**
     * 采购合同提交前
     * 此采购合同是否绑定充足的货款
     *
     * @param cght
     * @return
     */
    public String checkHthkFromCght(Cght cght) {
        String result = "";
        DecimalFormat df = new DecimalFormat("0.00");
        List<Hthk> hthkList = this.hthkService.findHthkByCght(cght);
        if (null != hthkList && hthkList.size() > 0) {
            //1、这个采购合同额含税金额
            Double hthsje = cght.getHsze();
            Double sumSkje = 0.0;
            for (Hthk hthk : hthkList) {
                sumSkje += hthk.getJe();
            }
            Double d1 = CalcUtils.round(Double.valueOf(df.format(sumSkje)), 2);
            Double d2 = CalcUtils.round(Double.valueOf(df.format(hthsje)), 2);
            if (d1 < d2) {
                result = "此合同所需合同货款不足，还差" + df.format(d2 - d1) + "元，请确认！";
            }
        } else {
            result = "此合同未绑定货款!请绑定货款后再提交!";
        }
        return result;
    }
/*
    public String checkHthkFromCght1(Long cghtId) {
        String result = "";
        DecimalFormat df = new DecimalFormat("0.00");
        Cght cght = this.cghtDao.get(cghtId);
        List<Hthk> hthkList = this.hthkDao.findHthkByCght1(cghtId);
        if (null != hthkList && hthkList.size() > 0) {
            //1、这个采购合同额含税金额
            Double hthsje = cght.getHsze();
            Double sumSkje = 0.0;
            for (Hthk hthk : hthkList) {
                sumSkje += hthk.getJe();
            }
            Double d1 = CalcUtils.round(Double.valueOf(df.format(sumSkje)), 2);
            Double d2 = CalcUtils.round(Double.valueOf(df.format(hthsje)), 2);
            if (d1 < d2) {
                result = "此合同所需合同货款不足，还差" + df.format(d2 - d1) + "元，请确认！";
            }
        } else {
            result = "此合同未绑定货款!请绑定货款后再提交!";
        }
        return result;
    }
*/


    public String checkHthkFromCght1(Long cghtId) {
        String result = "";
        DecimalFormat df = new DecimalFormat("0.00");
        Cght cght = this.cghtDao.get(cghtId);
        List<Hthk> hthkList = this.hthkDao.findHthkByCght1(cghtId);
        if (null != hthkList && hthkList.size() > 0) {
            //1、这个采购合同额含税金额
            Double hthsje = cght.getHsze();
            Double sumSkje = 0.0;
            for (Hthk hthk : hthkList) {
                sumSkje += hthk.getYe();
            }
            Double d1 = CalcUtils.round(Double.valueOf(df.format(sumSkje)), 2);
            Double d2 = CalcUtils.round(Double.valueOf(df.format(hthsje)), 2);
            if (d1 < d2) {
                result = "此合同所需合同货款不足，还差" + df.format(d2 - d1) + "元，请确认！";
            }
        } else {
            result = "此合同未绑定货款!请绑定货款后再提交!";
        }
        return result;
    }

    public String checkJzjsFromCght1(Long cghtId) {
        Cght cght = this.cghtDao.get(cghtId);
        String result = "";
        DecimalFormat df = new DecimalFormat("0.00");
        List<Jzjs> jzjsList = this.jzjsDao.checkHtJzjs(cghtId);
        if (null != jzjsList && jzjsList.size() > 0) {
            //1、这个采购合同额含税金额
            Double hthsje = cght.getHsze();
            Double sumSkje = 0.0;
            for (Jzjs jzjs : jzjsList) {
                sumSkje += jzjs.getJe();
            }
            Double d1 = CalcUtils.round(Double.valueOf(df.format(sumSkje)), 2);
            Double d2 = CalcUtils.round(Double.valueOf(df.format(hthsje)), 2);
            if (d1 < d2) {
                result = "此合同所需居中结算不足，还差" + df.format(d2 - d1) + "元，请确认！";
            }
        } else {
            result = "此合同未居中结算!";
        }
        return result;
    }


    @Transactional
    public void editBght(Cght bght, String htbm) {
        bght.setHtbm(htbm);
        if (bght.getSl() != null) {
            java.text.DecimalFormat df = new java.text.DecimalFormat("#0.0000");
            String sl = df.format(bght.getSl());
            bght.setSl(Double.parseDouble(sl));
        }
        if (bght.getLl() != null) {
            java.text.DecimalFormat df = new java.text.DecimalFormat("#0.0000");
            String ll = df.format(bght.getLl());
            bght.setLl(Double.parseDouble(ll));
        }
        bght.setLastUpdated(new Date());
        this.cghtDao.save(bght);
    }

    /**
     * 删除采购合同信息
     *
     * @param id 采购合同ID
     * @return
     */
    @Transactional
    public Cght deleteCght(Long id) {
        Cght cght = this.cghtDao.get(id);
        cght.setDeleted(1);
        cght.setLastUpdated(new Date());
        this.cghtDao.save(cght);
        this.cghtDao.deleteHtmx(id);
        return cght;
    }

    @Transactional
    public Cght tjCght(Long id) {
        Cght cght = this.cghtDao.get(id);
        cght.setZt("ysp");
        cght.setLastUpdated(new Date());
        cgdDao.jsCgdUpdate(cght.getId());
        this.cghtDao.save(cght);
        return cght;
    }

    /**
     * 履约采购合同信息
     *
     * @param id 采购合同ID
     * @return
     */
    @Transactional
    public void agreeCght(Long id) {
        Cght cght = this.cghtDao.get(id);
        Jkpz jkpz = jkpzDao.findByBm("cght");
        if (jkpz.getFlag()) {
            String json = this.createJsonToCkFromCght(cght, 1);
            String result = this.webserviceTransService.transCghtWebServiceArgs(json);
            Gson gson = new Gson();
            if (result != null) {
                Map<String, Object> resultMap = gson.fromJson(result, new TypeToken<Map<String, Object>>() {
                }.getType());
                if (resultMap != null && resultMap.get("code").equals("0")) {
                    //采购合同提交仓储系统成功！
                    cght.setZt("yly");
                    cght.setLastUpdated(new Date());
                } else
                    throw new RuntimeException((String) resultMap.get("message"));
            } else
                throw new RuntimeException("提交的采购合同到仓库接口失败,请重新提交");
        } else {
            //不走接口
            cght.setZt("yly");
            cght.setLastUpdated(new Date());
        }
        this.cghtDao.save(cght);
    }

    /**
     * 终止采购合同信息
     *
     * @param id 采购合同ID
     * @return
     */
    @Transactional
    public void stopCght(Long id) {
        Cght cght = this.cghtDao.get(id);
        Jkpz jkpz = jkpzDao.findByBm("cght");
        if (jkpz.getFlag()) {
            String json = this.createJsonToCkFromCght(cght, 1);
            String result = this.webserviceTransService.transCghtWebServiceArgs(json);
            Gson gson = new Gson();
            if (result != null) {
                Map<String, Object> resultMap = gson.fromJson(result, new TypeToken<Map<String, Object>>() {
                }.getType());
                if (resultMap != null && resultMap.get("code").equals("0")) {
                    //采购合同提交仓储系统成功！
                    cght.setZt("yzz");
                    cght.setLastUpdated(new Date());
                } else
                    throw new RuntimeException((String) resultMap.get("message"));
            } else
                throw new RuntimeException("提交的采购合同到仓库接口失败,请重新提交");
        } else {
            //不走接口
            cght.setZt("yzz");
            cght.setLastUpdated(new Date());
        }
        this.cghtDao.save(cght);
    }


    /**
     * 查询保供付款方式列表
     *
     * @param bghtId
     * @return
     */
    public String findBgFkfsList(Long bghtId) {
        List<Bgfkfs> list = this.cghtDao.find("select new map(fksj as fksj,fkbl as fkbl,isyf as isyf) from Bgfkfs where bght.id = ?", bghtId);
        return "{\"total\":" + list.size() + ",\"rows\":" + new Gson().toJson(list) + "}";
    }


    /**
     * 查询付款方式列表
     *
     * @param htId
     * @return
     */
    public String findFkfsList(Long htId) {
        List<Fkfs> list = this.cghtDao.find("select new map(id as id,fkgs as fkgs,fksjStart as fksjStart,fksj as fksj,fkll as fkll) from Fkfs where ht.id = ?", htId);
        if (list == null) list = new ArrayList<Fkfs>();
        return "{\"total\":" + list.size() + ",\"rows\":" + new Gson().toJson(list) + "}";
    }

    @Transactional
    public String findFkfsByhtId(Long htId) {
        List<Map> allPage = this.fkfsDao.findFkfsByhtId(htId);
        Gson gson = new Gson();
        String result = gson.toJson(allPage);
        return result;
    }


    /**
     * 保存保供付款方式信息
     *
     * @param list
     * @param bghtId
     */
//    @Transactional
//    public void saveBgfkfs(List<Bgfkfs> list, Long bghtId) {
//        this.cghtDao.executeSQL("delete from t_biz_bgfkfs where bght_id = ?", bghtId);
//        Cght bght = cghtDao.get(bghtId);
//        bght.setBgFkfs(list);
//        cghtDao.save(bght);
//    }


    /**
     * 查询保供合同的合同定义
     *
     * @param bghtId
     * @return
     */
    public Long findHtdyId(Long bghtId) {
        try {
            String htdySql = "select tx.bgjh_id from t_biz_ht th, t_biz_htmx tm,t_biz_htjhdz tz,t_biz_bgjhhzmx tbj,t_biz_bgjhmx tx" +
                    "  where th.id = tm.ht_id and tm.contractdetailid = tz.bghtmxid and tz.detailid = tbj.id and tbj.bgjhmx_id = tx.id and th.id = ?";
            List list = this.cghtDao.findBySQL(htdySql, bghtId);
            if (null != list && list.size() > 0) {
                BigDecimal bgjhId = (BigDecimal) list.get(0);
                return this.bgjhDao.get(Long.valueOf(bgjhId.toString())).getLj().getCghtmb().getId();
            }
        } catch (Exception e) {
            e.printStackTrace();

        }
        return null;
    }

    /**
     * 审核保供合同
     *
     * @param bghtId
     */
    @Transactional
    public void checkBght(Long bghtId) {
        if (null != bghtId) {
            Cght bght = cghtDao.get(bghtId);
            if (bght.getBgFkfs() != null && bght.getBgFkfs().size() != 0) {
                // 更新合同为已审批
                String htSql = "update t_biz_ht th set th.zt = ? ,th.last_updated = sysdate  where th.id = ?";
                this.cghtDao.executeSQL(htSql, "ysp", bghtId);
                // 更新扩展表
                String htkzSql = "update t_biz_htkz tz set tz.spr = ? , tz.sprq = sysdate where tz.ht_id = ?";
                this.cghtDao.executeSQL(htkzSql, YgService.getCurrentYg().getXm(), bghtId);
                //更新计划汇总明细采购方式为招标状态为计划科已处理
                if (bght.getZbbj() == 2)
                    if (bght.getHtmxList() != null && bght.getHtmxList().size() != 0) {
                        for (Htmx htmx : bght.getHtmxList()) {
                            bgjhhzmxDao.cgfsUpdate(htmx.getWzgg().getId());
                        }
                    }
            } else {
                throw new RuntimeException("审核失败，付款方式必须维护!");
            }
        }
    }

    //
//    public Page<Map> findBgjhCght(Date startDate, Date endDate, String wzdl, String wzbm, Long jhdwId, int pageNo, int pageSize){
//       return this.cghtDao.findBgjhCght(startDate,endDate,wzdl,wzbm,jhdwId,pageNo,pageSize);
//    }
    @Transactional
    public String findBgjhCght(Date startDate, Date endDate, String wzdl, String wzbm, Long jhdwId, String htbm, Long gysid, int pageNo, int pageSize) {
        Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
        Page bgcgdPage = this.cghtDao.findBgjhCght(startDate, endDate, wzdl, wzbm, jhdwId, htbm, gysid, pageNo, pageSize);
        String bgcgdJson = gson.toJson(bgcgdPage.getResult());
        return "{\"total\":" + bgcgdPage.getTotalCount() + ",\"rows\":" + bgcgdJson + "}";
    }


    public String findbzjList(Long cghtId) {
        Gson gson = new Gson();
        String result = "";

        List<Map> xsdbzjList = this.cghtDao.findbzjList(cghtId);

        result = "{\"rows\":" + gson.toJson(xsdbzjList) + "}";

        return result;
    }

    public Cght findCghtByHtbm(String htbm) {
        return this.cghtDao.findCghtByHtbm(htbm);
    }

    /**
     * 采购合同提交仓储系统
     *
     * @param id
     */
    //todo
    @Transactional
    public void cghtTjCk(Long id) {
        Cght cght = this.cghtDao.get(id);
        Jkpz jkpz = jkpzDao.findByBm("cght");
        if (jkpz.getFlag()) {
            String json = this.createJsonToCkFromCght(cght, 0);
            if (StringUtils.isNotBlank(json)) {
                String result = this.webserviceTransService.transCghtWebServiceArgs(json);
                Gson gson = new Gson();
                if (result != null) {
                    Map<String, Object> resultMap = gson.fromJson(result, new TypeToken<Map<String, Object>>() {
                    }.getType());
                    if (resultMap != null && resultMap.get("code").equals("0")) {
                        //采购合同提交仓储系统成功！
                        cght.setZt("ysp");
                        cght.setCkZt(1);
                        cghtDao.save(cght);
                    } else
                        throw new RuntimeException((String) resultMap.get("message"));
                } else {
                    throw new RuntimeException("提交的采购合同到仓库接口失败,请重新提交");
                }
            } else {
                throw new RuntimeException("合同明细中，合同子项号输入可能有误,请检查后提交");
            }
        } else {
            //不走接口
            String jsonItem = createResponseJsonFromCght(cght);
            String serialNumber = String.valueOf(System.currentTimeMillis());
            try {
                //1、查出所有已审批的采购合同
                putStorageFeedbackService.updateCghtAndCreateCgdAndCreateKh(jsonItem, serialNumber);
            } catch (Exception e) {
                throw new RuntimeException("提交的采购合同到仓库接口失败,请重新提交");
            }
        }

    }

    //拼json采购合同信息
    private String createJsonToCkFromCght(Cght cght, Integer endFlag) {
        try {
            StringBuffer sb = new StringBuffer();
            sb.append("[");
            for (Htmx cghtmx : cght.getHtmxList()) {
                String xsxt_xsdh = cghtmx.getXsxt_xsdh().trim();
                String X = xsxt_xsdh.substring(2, 3);
                if (X.equals("X")) {
                    String s_1 = xsxt_xsdh.substring(0, 2);
                    String s_2 = xsxt_xsdh.substring(3, xsxt_xsdh.length());
                    xsxt_xsdh = s_1 + "S" + s_2;
                }
                sb.append("{\"sellSubNo\":\"").append(xsxt_xsdh).append("\",");
                sb.append("\"endFlag\":\"").append(endFlag).append("\"},");
            }
            sb = sb.deleteCharAt(sb.length() - 1);
            sb.append("]");
            String json = sb.toString();
            return json;
        } catch (Exception e) {

        }
        return "";
    }


    //不走接口 模拟拼数据
    private String createResponseJsonFromCght(Cght cght) {
        StringBuffer sb = new StringBuffer();
        Xsht xsht = xshtDao.findXshtByCght(cght.getId());
        sb.append("[");
        int i = 1;
        for (Htmx cghtmx : cght.getHtmxList()) {
            String wh = "";
            if (i < 10) {
                wh = "0" + i;
            } else {
                wh = String.valueOf(i);
            }
            sb.append("{\"buyerCompany\":\"").append(cght.getSbgs().getQc()).append("\",");
            sb.append("\"reportCompany\":\"").append(xsht.getHzf().getQc()).append("\",");
            sb.append("\"name\":\"").append(cghtmx.getWzgg().getName().trim()).append("\",");
            sb.append("\"quality\":\"").append(cghtmx.getWzgg().getCz().trim()).append("\",");
            sb.append("\"standard\":\"").append(cghtmx.getWzgg().getGgxh().trim()).append("\",");
            sb.append("\"field\":\"").append(cghtmx.getCd().getZ()).append("\",");
            sb.append("\"warehouse\":\"").append(cght.getCk().getMc()).append("\",");
            sb.append("\"carNo\":\"").append("川" + String.valueOf(System.currentTimeMillis()).substring(0, 7)).append("\",");
            sb.append("\"sellSubNo\":\"").append(cghtmx.getXsxt_xsdh()).append("\",");
            sb.append("\"bindNo\":\"").append(String.valueOf(System.currentTimeMillis())).append("\",");
            sb.append("\"FDate\":\"").append(DateUtil.getDate(new Date())).append("\",");
            sb.append("\"resource_serial_number_1\":\"").append(String.valueOf(System.currentTimeMillis()) + wh).append("\",");
            sb.append("\"numberUnit\":\"").append("件").append("\",");
            sb.append("\"number\":\"").append("1").append("\",");

            sb.append("\"weightUnit\":\"").append(cghtmx.getWzgg().getDw() == null ? "" : cghtmx.getWzgg().getDw()).append("\",");
            sb.append("\"weight\":\"").append(cghtmx.getSbsl()).append("\"},");
            i++;
        }
        sb = sb.deleteCharAt(sb.length() - 1);
        sb.append("]");
        String json = sb.toString();
        return json;
    }

    @Transactional
    public Cght findByCghtId(Long CghtId) {
        return cghtDao.findByCghtId(CghtId);
    }
    @Transactional
    public synchronized String findhqmxList(String xhtbm) throws Exception {
        String res = "{\"rows\":";
        String json = JsonUtils.createhqmx1ListJson(xhtbm);
        // String result = this.webserviceTransService.transhqmxWebServiceArgs(json);
        String result = JsonUtils.createZyfKcxxListResultJson1();
        Gson gson = new Gson();
        if (result != null) {
            JSONArray jsonArray = new JSONArray(result);
            int iSize = jsonArray.length();
            if (jsonArray != null && iSize > 0) {
                //---
               /* for (int i = 0; i < iSize; i++) {
                JSONObject jsonObj = jsonArray.getJSONObject(i);
                    String wzgg_name = (String) jsonObj.get("prodDscr");//物资名称  品名（中文）
                    String wzgg_ggxh = (String) jsonObj.get("specDesc");//规格型号  规格描述
                    String wzgg_cz = (String) jsonObj.get("shopsign");//材质   材质
                    String wzgg_dw = (String) jsonObj.get("orderUnitCode");//单位   单位
                    String cd_z = (String) jsonObj.get("factoryId");//产地     工厂
                    String sbjs = (String) jsonObj.get("materialN");//件数     准发件数
                    String sbsl = (String) jsonObj.get("stockingWt");//重量     准发净重
                    String jzfs_z = (String) jsonObj.get("weightMethod");//记重方式   计重方式
                    String hsj = (String) jsonObj.get("actUnitprice");//含税单价     含税单价
                    String xsxt_xsdh = (String) jsonObj.get("orderItemNum");//销售系统子项号   客户订单子项号
                    String spec = (String) jsonObj.get("specDesc");//特点   specDesc
                    Gg gg = ggDao.findByPro_2(wzgg_name, wzgg_ggxh, wzgg_cz);
                    if (gg == null) {
                          = wzbmService.saveFree(wzgg_name, wzgg_ggxh, wzgg_cz);//根据销售系统自动新建物资
                    }

                    StringBuffer sb = new StringBuffer();
                    sb.append("[");
                    sb.append("{\"wzgg.name\":\"").append(gg.getName()).append("\",");
                    sb.append(" \"wzgg.id\":\"").append(gg.getId()).append("\",");
                    sb.append(" \"wzgg.code\":\"").append(gg.getCode()).append("\",");
                    sb.append(" \"wzgg.ggxh\":\"").append(gg.getGgxh()).append("\",");
                    sb.append("\"wzgg.cz\":\"").append(gg.getCz()).append("\",");
                    sb.append("\"wzgg.dw\":\"").append(gg.getDw()).append("\",");
                    sb.append("\"cd.z\":\"").append(cd_z).append("\",");
                    sb.append("\"sbjs\":\"").append(sbjs).append("\",");
                    sb.append("\"sbsl\":\"").append(sbsl).append("\",");
                    sb.append("\"jzfs.z\":\"").append(jzfs_z).append("\",");
                    sb.append("\"hsj\":\"").append(hsj).append("\",");
                    sb.append("\"xsxt_xsdh\":\"").append(xsxt_xsdh).append("\",");
                    sb.append("\"spec\":\"").append(spec).append("\"}");
                    sb = sb.deleteCharAt(sb.length() - 1);
                    sb.append("]");
*/
                //---
                res = res + jsonArray.toString();

                //  }

            } else
                throw new RuntimeException("反馈数据为空");
        } else
            throw new RuntimeException("提交的信息接口失败,请重新提交");

        return res + "}";
    }

    public Jydd findJydd(String orderSn) {
        return this.jyddDao.checkOrderSn(orderSn);
    }


    @Autowired
    public void setCghtDao(CghtDao cghtDao) {
        this.cghtDao = cghtDao;
    }


    @Autowired
    public void setBmService(BmService bmService) {
        this.bmService = bmService;
    }

    @Autowired
    public void setNbgsDao(NbgsDao nbgsDao) {
        this.nbgsDao = nbgsDao;
    }

    @Autowired
    public void setBgjhDao(BgjhDao bgjhDao) {
        this.bgjhDao = bgjhDao;
    }

    @Autowired
    public void setBgjhhzmxDao(BgjhhzmxDao bgjhhzmxDao) {
        this.bgjhhzmxDao = bgjhhzmxDao;
    }

    @Autowired
    public void setFkfsDao(FkfsDao fkfsDao) {
        this.fkfsDao = fkfsDao;
    }

    @Autowired
    public void setBzjService(BzjService bzjService) {
        this.bzjService = bzjService;
    }

    @Autowired
    public void setWebserviceTransService(WebserviceTransService webserviceTransService) {
        this.webserviceTransService = webserviceTransService;
    }

    @Autowired
    public void setXshtDao(XshtDao xshtDao) {
        this.xshtDao = xshtDao;
    }

    @Autowired
    public void setJkpzDao(JkpzDao jkpzDao) {
        this.jkpzDao = jkpzDao;
    }

    @Autowired
    public void setPutStorageFeedbackService(PutStorageFeedbackService putStorageFeedbackService) {
        this.putStorageFeedbackService = putStorageFeedbackService;
    }

    @Autowired
    public void setBzjyjDao(BzjyjDao bzjyjDao) {
        this.bzjyjDao = bzjyjDao;
    }

    @Autowired
    public void setHthkService(HthkService hthkService) {
        this.hthkService = hthkService;
    }

    @Autowired
    public void setSkshDao(SkshDao skshDao) {
        this.skshDao = skshDao;
    }

    @Autowired
    public void setHthkDao(HthkDao hthkDao) {
        this.hthkDao = hthkDao;
    }

    @Autowired
    public void setBzjDao(BzjDao bzjDao) {
        this.bzjDao = bzjDao;
    }

    @Autowired
    public void setJzjsDao(JzjsDao jzjsDao) {
        this.jzjsDao = jzjsDao;
    }

    @Autowired
    public void setCgdDao(CgdDao cgdDao) {
        this.cgdDao = cgdDao;
    }

    @Autowired
    public void setJyddDao(JyddDao jyddDao) {
        this.jyddDao = jyddDao;
    }
}
